/**
  ******************************************************************************
  * @file    Project/STM32F10x_StdPeriph_Template/main.c 
  * @author  MCD Application Team
  * @version V3.5.0
  * @date    08-April-2011
  * @brief   Main program body
  ******************************************************************************
  * @attention
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
  ******************************************************************************
  */  

/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"
#include "./led/led.h"
#include "./usart/usart.h"
#include "./key/key.h"
#include "./flash/flash.h"
#include "sys.h"
#include "./i2c/i2c.h"
#include "OLED.h"
#include "./spi/spi.h"
#include "TFT.h"
#include "./circularqueue/circularqueue.h"

extern circularqueue_t usart1_cq;

/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{	
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
	delay_init();
	led_init();
	usart1_init(115200);
	CircularQueue_Init(&usart1_cq);
	key_init();
//	uint8_t key = 0;
	uint8_t popvalue = 0;
//	printf("Hello,World!\r\n");
	
	
	/* Infinite loop */
	while (1)
	{
//		key = key_scan(0);
//		if(key == KEY0_PRES)
//		{
//			bool ret = CircularQueue_Pop(&usart1_cq, &popvalue);
//			if(ret == true)
//			{
//				printf("%c", popvalue);
//			}			
//		}
		if(CircularQueue_isEmpty(&usart1_cq) == false)
		{
			bool ret = CircularQueue_Pop(&usart1_cq, &popvalue);
			if(ret == true)
			{
				printf("%c", popvalue);
			}			
		}
//		LED0(0);
////		OLED_On();
//		delay_ms(15);
//		LED0(1);
////		OLED_Clear();
//		delay_ms(15);	
	}
}






/******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
